<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

return [
    '__pattern__' => [
        'name' => '\w+',
        'id' => '\d+',
        'uid' => '\d+',
        'version' => '\w+',
    ],
    '[hello]'     => [
        ':id'   => ['index/hello', ['method' => 'get'], ['id' => '\d+']],
        ':name' => ['index/hello', ['method' => 'post']],
    ],
    // 添加路由规则 路由到index控制器的test方法
    'test/[:name]$' => ['index/test',['method' => 'get','ext'=>'html']],
    // 添加blog路由规则
    /* 'blog/:year/:month' => ['blog/archive',['method'=>'get'],['year'=>'\d{4}'],['month'=>'\d{2}']],
    'blog/:name' => ['blog/read',['method'=>'get'],['name'=>'\w+']],
    'blog/:id' => ['blog/get',['method'=>'get'],['id'=>'\d+']], */
    // 路由分组
    '[blog]' => [
        ':year/:month' => ['blog/archive',['method'=>'get'],['year'=>'\d{4}'],['month'=>'\d{2}']],
        ':name' => ['blog/read',['method'=>'get'],['name'=>'\w+']],
        ':id' => ['blog/get',['method'=>'get'],['id'=>'\d+']], 
    ],

    // 学习模型和关联，添加的测试路由
    'user/index' => 'index/user/index',
    'user/create' => 'index/user/create',
    'user/add' => 'index/user/add',
    'user/add2' => 'index/user/add2',
    'user/add_list' => 'index/user/addList',
    'user/update/:id' => 'index/user/update',
    'user/delete/:id' => 'index/user/delete',
    'user/:id' => 'index/user/read',
    'user/read2' => 'index/user/read2',

    // 关联模型 路由
    '[user2]' => [
        'add' => ['index/user2/add'],
        ':id' => ['index/user2/read'],
        'update/:id' => ['index/user2/update'],
        'delete/:id' => ['index/user2/delete'],
        'add_book/:uid' => ['index/user2/addBook'],
        'add_books/:uid' => ['index/user2/addBooks'],
        'read_byuid/:uid' => ['index/user2/readByuid'],
        'delete_book/:uid' => ['index/user2/deleteBook'],
        'delete_books/:uid' => ['index/user2/deleteBooks'],
        'add3/:id' => ['index/user2/add3'],
    ],

    // 模型输出，路由
    '[user3]' => [
        ':id' => ['index/user3/read'],
        '' => ['index/user3/index'],
    ],

    // 视图和模板，路由
    '[test]' => [
        '' => ['test/index/index']
    ],
    

];

Route::rule(':version/user/:id','api/:version.User/read');
